const { ccclass, property } = cc._decorator;

import o from "./PlayerDataSys"
import i from "./frameworkManager"
import n from "./FormData"

@ccclass
export default class ClientData {

    public static l = {
        aid: "android_id",
        madr: "mac_addr",
        wmr: "wifi_mac_addr",
        platform: cc.sys.os == cc.sys.OS_ANDROID ? "os_name" : "platform"
    }

    public static device_id = "";
    public static version_name = "";
    public static channel_name = "";
    public static box_pkg_name = "";
    public static imei = "";
    public static android_id = "";
    public static mac_addr = "";
    public static wifi_mac_addr = "";
    public static oaid = "";
    public static platform = "";
    public static os_name = "";
    public static os_version = "";
    public static phone_model = "";
    public static phone_brand = "";
    public static device_type = "";
    public static mdi = "";
    public static rii = "";
    public static ii = "";
    public static device_serial = "";
    public static Longitude = "";
    public static Latitude = "";
    public static session_id = "";
    public static network_type = "";
    public static idfa = "";
    public static caid = "";
    public static caid_version = "";
    public static last_caid = "";
    public static last_caid_version = "";
    public static url_common_str = "";
    public static cookie_str = "";
    public static form_str = "";
    public static yid = "yid_read_failed";

    static init(t) {
        console.log("参数");
        console.log(t);
        this.caid = t.caid || "";
        this.caid_version = t.caid_version || "";
        this.last_caid_version = t.last_caid_version || "";
        this.last_caid = t.last_caid || "";
        this.idfa = t.idfa || "";
        this.platform = t.platform || "";
        this.version_name = t.version_name || "";
        this.device_id = t.device_id || "";
        this.channel_name = t.channel_name || "";
        this.device_serial = t.device_serial || "";
        this.box_pkg_name = t.box_pkg_name || "";
        this.imei = t.imei || "";
        this.oaid = t.oaid || "";
        this.Latitude = t.Latitude || "";
        this.Longitude = t.Longitude || "";
        this.os_version = t.os_version || "";
        this.phone_model = t.phone_model || "";
        this.phone_brand = t.phone_brand || "";
        this.os_name = t.os_name || "";
        this.device_type = t.device_type || "";
        this.session_id = t.session_id || "";
        this.network_type = t.network_type || "";
        this.mdi = t.mdi || "";
        this.ii = t.ii || "";
        this.rii = t.rii || "";
        this.mac_addr = t.madr || "";
        this.wifi_mac_addr = t.wmr || "";
        this.android_id = t.aid || "";

        this.setCommonData();
    }

    static clear() {
        this.idfa = "";
        this.platform = "";
        this.version_name = "";
        this.device_id = "";
        this.channel_name = "";
        this.device_serial = "";
        this.box_pkg_name = "";
        this.imei = "";
        this.oaid = "";
        this.Latitude = "";
        this.Longitude = "";
        this.os_version = "";
        this.phone_model = "";
        this.phone_brand = "";
        this.os_name = "";
        this.device_type = "";
        this.session_id = "";
        this.network_type = "";
        this.mdi = "";
        this.ii = "";
        this.rii = "";
        this.mac_addr = "";
        this.wifi_mac_addr = "";
        this.android_id = "";
    }

    static setCommonData() {
        this.genUrlString();
        this.genFormData();
    }

    static getAttr(t) {
        // return this[l[t] ? l[t] : t];
        return "";
    }

    static genUrlString() {
        // var t = r.getInstance().getVersion();
        // var a = r.getInstance().getBaseVersion();
        // console.log("baseVersion:" + a + ",nowVersion:" + t);

        // var n = "";
        // var s = ["version_name", "channel_name", "box_pkg_name", "ii", "idfa", "platform", "madr", "wmr", "oaid", "os_version", "phone_model", "phone_brand", "device_id"];

        // for (var c = 0; c < s.length; c++) {
        //     var u = s[c];
        //     var p = encodeURI(this[l[u] ? l[u] : u]);
        //     if (p !== "" && p !== null) {
        //         n += "&" + u + "=" + p;
        //     }
        // }

        // n = "user_id=" + o.user_id + n;

        // if (t) {
        //     n += "&game_version=" + t + "&base_version=" + a;
        // }

        this.url_common_str = "";
    }

    setCookieString() {
        // var t = "";
        // var a = ["device_id", "ii", "aid", "madr", "idfa", "wmr", "mdi", "rii"];

        // for (var i = 0; i < a.length; i++) {
        //     var r = a[i];
        //     var n = this[l[r] ? l[r] : r];
        //     if (n !== "" && n !== null) {
        //         t += "; " + r + "=" + n;
        //     }
        // }

        // t = "yid=" + o.yid + t;
        // this.cookie_str = t;
        // document.cookie = this.cookie_str;
    }

    static genFormData(t?) {
        // this.yid = t !== null ? this.yid : t;
        // var a = this.yid;
        // var o = new n();
        // o.append("yid", a !== null ? a : "yid_read_fail");

        // var i = this[l.device_id ? l.device_id : "device_id"];
        // if (i !== "") {
        //     o.append("device_id", i);
        // }

        return {};
    }

    static getVersionData() {
        var t = "";
        // var a = ["box_pkg_name", "channel_name", "device_id"];

        // for (var o = 0; o < a.length; o++) {
        //     var i = a[o];
        //     var r = this[l[i] ? l[i] : i];

        //     if (r !== "" && r !== null) {
        //         t += (t === "" ? t : "&") + i + "=" + r;
        //     }
        // }

        return t;
    }
}